package com.company.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.base.common.persistence.Page;
import com.base.common.service.CrudService;
import com.company.dao.ProjectWorkHoursMapper;
import com.company.model.CompanyProject;
import com.company.model.ProjectWorkHours;
import com.company.service.ProjectWorkHoursService;

@Service
public class ProjectWorkHoursServiceImpl extends
		CrudService<ProjectWorkHoursMapper, ProjectWorkHours> implements
		ProjectWorkHoursService {

	public Page<ProjectWorkHours> findProjectWHPageByProjectId(String projectId,
			Page page) throws Exception {
		Map<String, String> params = new HashMap<String, String>();
		params.put("projectId", projectId);
		String sql = "SELECT h.id,h.project_id,h.project_wbs_id,h.employee_id,e.name as employeeName, h.work_hours,w.wbs_name,w.del_flag,p.project_name "
				+ "FROM company_project  p ,project_wbs  w ,project_workhours  h, company_employee e "
				+ "WHERE h.project_wbs_id =  w.id AND h.project_id =  p.id and h.employee_id = e.id and h.project_id = #{projectId} ";
		page = this.getPage(page, sql, ProjectWorkHours.class, params);
		return page;
	}

}
